using System.Collections.Generic;
using System.Data;
using Caliburn.Micro;

namespace SimpleQueryTool.ViewModels.Workspace
{
	public class QueryResultViewModel : PropertyChangedBase, IHandle<ExecuteQueryResultMessage>
	{
        public QueryResultViewModel(IEventAggregator eventAggregator)
        {
        	eventAggregator.Subscribe(this);
        }

		private DataView _result;
		public DataView Result
		{
			get { return _result; }
			set
			{
				_result = value;
				NotifyOfPropertyChange(() => Result);
			}
		}

		public void Handle(ExecuteQueryResultMessage message)
		{
			Result = message.Result.DefaultView;
		}
	}
}